const express = require('express');
const app = express();

app.use(express.static(__dirname));

app.get('/clock', function (req, res) {
  const $timer = setInterval(function () {
    const date = new Date();
    const seconds = new Date().getSeconds();
    if (seconds % 5 === 0) {
      res.send(date.toLocaleString()); // 注意如果长时间(2min)没有返回 http连接会断开
      clearInterval($timer);
    }
  }, 1000);

});

app.listen(8000);
